package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;

@Setter
@Getter
public class CourseOrder {
    private Long id;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime;

    private Customer customer;

    private Classinfo classinfo;

    private Long money;

    public String getJson(){
        HashMap map = new HashMap();
        map.put("id",id);
        map.put("money",money);
        if (customer != null){
            map.put("customerId",customer.getId());
            map.put("customerName",customer.getName());
        }
        if (classinfo != null){
            map.put("classinfoId",classinfo.getId());
            map.put("classinfoName",classinfo.getName());
        }
        //不能直接传this进去会出现死循环
        return JSON.toJSONString(map);
    }

}